package cn.kgc.service.impl;

import cn.kgc.mapper.UserMapper;
import cn.kgc.pojo.UserInf;
import cn.kgc.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserServiceimpl implements UserService {
    @Resource
    UserMapper userMapper;

    @Override
    public List<UserInf> getUser() {
        return userMapper.getUser();
    }

    @Override
    public UserInf getUserInfo(String loginname, String PASSWORD) {
        return userMapper.getUserInfo(loginname,PASSWORD);
    }

    @Override
    public int getCount(Integer status,String username) {
        return userMapper.getCount(status,username);
    }

    @Override
    public List<UserInf> getUserByPage(Integer currentPageNo, Integer pageSize, Integer status,String username) {
        Integer pageNo = (currentPageNo-1)*pageSize;
        return userMapper.getUserByPage(pageNo,pageSize,status,username);
    }

    @Override
    public UserInf getUserById(Integer id) {
        return userMapper.getUserById(id);
    }

    @Override
    public boolean updateUser(UserInf userInf) {
        int count = userMapper.updateUser(userInf);
        if (count>0){
            return true;
        }else {
            return false;
        }

    }

    @Override
    public boolean addUser(UserInf userInf) {
        int count = userMapper.addUser(userInf);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean delId(Integer id) {
        int count = userMapper.delId(id);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public UserInf getUserloginname(String loginname) {
        return userMapper.getUserloginname(loginname);
    }
}
